$(function() {
	$('#submitForm').validate({
		debug: true, //调试模式取消submit的默认提交功能   
        focusInvalid: false, 
        onkeyup: false,   
        submitHandler: function(form){  
            if (typeof jQuery.data(this, "disabledOnSubmit") == 'undefined') {
            	jQuery.data(this, "disabledOnSubmit", {submited : true});
            	form.submit();
            } else {
            	// repeat submit ignore;
            }
        },
        success:function(element){
        	element.siblings("span[class='red']").text("");
        },
		errorPlacement : function(error, element) {
			element.siblings("span[class='red']").text(error.text());
		},
        rules:{
			roomName:{required:true},
			roomCode:{
				required:true,
				remote:{
					url:appServer + '/goods/room/uniqueCode.json',
					type: "post",
                    dataType: "json",
                    data:{"roomCode":function(){return $("input[name='roomCode']").val();}}
				}
			},
			// compereId:{required:true}
        },
        messages:{
			roomName:{required:"房间名称必填"},
			roomCode:{required:"房间编号必填",remote:"房间编号已存在"},
			// compereId:{required:"主持人必填"}
        }
	});
});

function openCommissionRateWindow(id) {
	window.open(appServer+'/goods/getUser.htm?id='+id, 'newwindow', 'height=400, width=1000, top=20,left=150, toolbar=no, menubar=no, scrollbars=yes, resizable=no,location=no, status=no').focus();
}

function toAddPage(){
	window.location.href = appServer + "/goods/room/add.htm";
}